﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using WPFExcelReport.Helpers;
using System.Linq;
namespace WPFExcelReport
{

    public class YGRVV20Data : BaseFunction
    {
        public VVVLIEF VVVLIEF = new VVVLIEF();
        public ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        public INTEXDBC INTEXDBC
        {
            get
            {
                return app.INTEXDBC;
            }
        }
        public INTEXBL INTEXBL
        {
            get
            {
                return app.INTEXBL;
            }
        }
        public string UserID
        {
            get
            {
                return app.User;
            }
        }
        public bool checkVK07 = true;
        SETINTEXDB INTEXDB = new SETINTEXDB();
      
        public string UserName
        {
            get
            {
                return app.User;
            }
        }
        public YGRVV20Data()
            : base()
        {
            Helper.GetDate(ref date, ref year,ref month, ref day);
        }
        public DataSet LoadEnv()
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataRow dwData = null;
            dwData = INTEXDB.ICC_WFEVENTDEF.NewRow();
            dwData["MANDANT"] = "00";
            dwData["WFCLASS"] = "901";
            SResult = INTEXDBC.QueryICC_WFEVENTDEF(dwData, 2);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["WFEDES"] = Helpers.Helper.GetGB2312Value(row["WFEDES"].ToString().Trim());
            }
            SReturn.Merge(SResult); 
            
            return SReturn;
        }
        public DataSet QueryWFEVENTS(DataRow dwInput)
        {
            
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataRow dwData = null;
            try
            {
                dwData = INTEXDB.ICC_WFEVENTS.NewRow();
                dwData["MANDANT"] = dwInput["MANDANT"];
                dwData["WFEVENTS"] = dwInput["WFEVENTS"];
                dwData["CONTROL"] = "NO ";
                dwData["WFEUSER"] = dwInput["WFEUSER"];
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 5);
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            
            return SReturn;
        }
        public DataSet BuildData(string client, string VVSTATUS,string DSTART,string DEND)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();

            try
            {
                SResult = VVVLIEF.QueryVV(client, VVSTATUS, DSTART, DEND);
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("查询完成", StatusEventType.StopProgress);
            }
            return SReturn;
        }
  
     
    }
}